<template>
  <div class="buyer-header">
    <div class="nav">
      <ul>
        <li>百思凯首页</li>
        <li>请登录</li>
        <li>免费注册</li>
      </ul>
      <ul>
        <li>个人中心</li>
        <li>消息通知</li>
        <li>订单管理</li>
      </ul>
    </div>
    <div
      class="search-container"
      :style="{top: headerTop}"
    >
      <div class="logo-wrapper">
        <img @click="$router.push('/')" src="./img/black_logo.png">
      </div>
      <div class="search-wrapper">
        <ul themeBorder-2 class="select-type">
          <li>产品</li>
        </ul>
        <input placeholder="输入您想要的" themeBorder-2 type="text" name="">
        <button themeBorder-2>搜索</button>
      </div>
      <div class="button-wrapper">
        <button themeBorder-1 themeColor>购物车</button>
        <button theme>发布求购</button>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'BuyerHeader',
  data () {
    return {
      headerTop: ''
    }
  },
  methods: {
    initEvent () {
      window.addEventListener('scroll', () => {
        if (scrollY <= 30) {
          this.headerTop = 30 - scrollY + 'px'
        } else {
          this.headerTop = 0
        }
      })
    },
  },
  mounted () {
    this.initEvent()
  }
}
</script>

<style lang="scss" scoped>
.buyer-header {
  width: 100%;
  height: calc(1.6rem + 30px);
  box-sizing: border-box;
}
.nav {
  display: flex;
  justify-content: space-between;
  padding: 0 1rem;
  background: #F5F5F5;
  ul {
    display: flex;
    height: 30px; // 单位px
    line-height: 30px;  // 单位px
    li {
      cursor: pointer;
      color: #707070;
      font-size: .25rem;
    }
  }
  ul:first-child {
    li {
      margin-right: .8rem;
    }
  }
  ul:last-child {
    li {
      margin-left: .8rem;
    }
  }
}
.search-container {
  width: 100%;
  min-width: 24rem;
  position: fixed;
  height: 1.6rem;
  box-sizing: border-box;
  padding: 0 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #fff;
  z-index: 100;
  .logo-wrapper {
    font-size: 0;
    img {
      width: 7.82rem;
    }
  }
  .search-wrapper {
    display: flex;
    align-items: center;
    .select-type {
      cursor: pointer;
      box-sizing: border-box;
      height: 36px; // 单位px
      width: 1.5rem;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      border-right: 0;
      li {
        color: #707070;
      }
    }
    input {
      border-radius: unset;
      width: 5.5rem;
    }
    button {
      flex: none;
      box-shadow: unset;
      border-radius: unset;
      border-top-right-radius: 2px;
      border-bottom-right-radius: 2px;
      border-style: solid;
    }
  }
  .button-wrapper {
    flex: none;
    button {
      padding: 0 .5rem;
      font-size: .32rem;
      height: .76rem;
    }
    button:first-child {
      background: #fff;
      margin-right: .5rem;
    }
  }
}
</style>
